<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            height: 100vh;
            background-color: black;
            display: flex;
            justify-content: center;
        }

        #app {
            margin-top: 100px;
            color: #fff;
            max-width: 800px;

        }

        .input_box {
            display: flex;
            justify-content: center;
        }

        #app .input {
            width: 200px;
        }

        #app input {
            border: none;
            height: 30px;
            background-color: transparent;
            border-bottom: 1px solid #eee;
            margin-bottom: 10px;
            color: white;
        }

        #app input:focus,
        #app input:valid {
            outline: none;
        }

        #app button {
            background-color: transparent;
            padding: 15px;
            cursor: pointer;
            color: white;
            border-radius: 5px;
            font-size: 16px;
        }

        #app button:active {
            transform: scale(0.98);
        }

        #app .showbox .msgbox {
            margin-top: 50px;
            text-align: center;
            font-size: 80px;
        }

        #app .showbox .timebox {
            font-size: 30px;
            text-align: center;
            margin-top: 20px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="input_box">
            <div class="input">
                <label for="msg">事情:</label><br>
                <input type="text" v-model='msg' id="msg">
            </div>
            <div class='input'>
                <label for="time">时间:</label><br>
                <input type="number" v-model.trim.number='time' id="time">
            </div>
            <div>
                <button @click='handler'>确认</button>
            </div>
        </div>
        <div class="showbox" v-show='show'>
            <p class="msgbox" v-text='msgbox'></p>
            <p class="timebox" v-text='timebox'></p>
        </div>
    </div>

    <script>
        new Vue({
            el: "#app",
            data: {
                msg: '',
                time: '',
                show: '',
                msgbox: '',
                timebox: '',
            },
            methods: {
                handler() {
                    this.show = true;
                    this.msgbox = this.msg;
                    this.msg = '';
                    this.countdown(this.time);
                    this.time = '';
                },
                countdown(minutes) {
                    let endTime = minutes * 60 * 1000;
                    setInterval(() => {
                        endTime -= 1000;
                        let date = new Date(endTime);
                        let m = date.getMinutes();
                        let s = date.getSeconds();
                        console.log(m, s);
                        this.timebox = `还剩下${m}分钟${s}秒`;
                    }, 1000)
                }
            },
        })

    </script>
</body>

</html>